//
//  HLtcTableViewCell.m
//  Router
//
//  Created by Zhen Huang on 2018/6/29.
//  Copyright © 2018年 James. All rights reserved.
//

#import "HLtcTableViewCell.h"

@implementation HLtcTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self.contentView addSubview:self.wifi_nameLabel];
        [self.contentView addSubview:self.public_ipLabel];
        [self.contentView addSubview:self.stateLabel];
        [self.contentView addSubview:self.beforeOutPutLabel];
        [self.contentView addSubview:self.yesterDayOutPutLabel];
        [self.contentView addSubview:self.image];
    
    }
    return self;
}
- (UILabel *)wifi_nameLabel {
    if (!_wifi_nameLabel) {
        _wifi_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth / 3, 25)];
        _wifi_nameLabel.font = [UIFont fontWithName:PingFangSCRegular size:12];
        _wifi_nameLabel.textColor = [Networking colorWithHexString:@"#6A8FA6"];
        _wifi_nameLabel.textAlignment = 0;
    }
    return _wifi_nameLabel;
}
- (UILabel *)public_ipLabel {
    if (!_public_ipLabel) {
        _public_ipLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.wifi_nameLabel.right, 10, ScreenWidth / 3, 25)];
        _public_ipLabel.font = [UIFont fontWithName:PingFangSCRegular size:12];
        _public_ipLabel.textColor = [Networking colorWithHexString:@"#6A8FA6"];
        _public_ipLabel.textAlignment = 0;
    }
    return _public_ipLabel;
}
- (UILabel *)stateLabel {
    if (!_stateLabel) {
        _stateLabel = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth - 70 , 0, 70, 25)];
        _stateLabel.font = [UIFont fontWithName:PingFangSCRegular size:12];
        _stateLabel.textColor = [UIColor whiteColor];
        _stateLabel.textAlignment = 1;
    }
    return _stateLabel;
}
- (UILabel *)beforeOutPutLabel {
    if (!_beforeOutPutLabel) {
        _beforeOutPutLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, self.wifi_nameLabel.bottom + 7, ScreenWidth / 3, 25)];
        _beforeOutPutLabel.font = [UIFont fontWithName:PingFangSCRegular size:15];
        _beforeOutPutLabel.textColor = [Networking colorWithHexString:@"#93B5CF"];
        _beforeOutPutLabel.textAlignment = 0;
    }
    return _beforeOutPutLabel;
}
- (UILabel *)yesterDayOutPutLabel {
    if (!_yesterDayOutPutLabel) {
        _yesterDayOutPutLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.wifi_nameLabel.right, self.wifi_nameLabel.bottom + 7, ScreenWidth / 3 * 2, 25)];
        _yesterDayOutPutLabel.font = [UIFont fontWithName:PingFangSCRegular size:12];
        _yesterDayOutPutLabel.textColor = [Networking colorWithHexString:@"#6A8FA6"];
        _yesterDayOutPutLabel.textAlignment = 0;
    }
    return _yesterDayOutPutLabel;
}
- (UIImageView *)image {
    if (!_image) {
        _image = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth - 40, self.yesterDayOutPutLabel.top, 20, 20)];
        _image.image = [UIImage imageNamed:@"round_right"];
        _image.centerX = self.stateLabel.centerX;
    }
    return _image;
}
- (void)setTempModel:(HLtcModel *)tempModel {
    self.wifi_nameLabel.text = tempModel.wifi_name;
    self.public_ipLabel.text = [NSString stringWithFormat:@"%@/%@",tempModel.disk_used?:@"",tempModel.disk_size?:@""];
    self.beforeOutPutLabel.text = [NSString stringWithFormat:@"昨收:%.2f",tempModel.yesterday_output];
    self.yesterDayOutPutLabel.text = [NSString stringWithFormat:@"%@/%@",tempModel.wan_ip?:@"",tempModel.public_ip?:@""];
    if (tempModel.is_online) {
        if (!tempModel.is_mount) {
            self.stateLabel.text = @"掉盘";
            self.stateLabel.backgroundColor = [Networking colorWithHexString:@"#FCA800"];
        }else {
            self.stateLabel.text = @"在线";
            self.stateLabel.backgroundColor = [Networking colorWithHexString:@"#00C3A2"];
        }
    }else {
        self.stateLabel.text = @"离线";
        self.stateLabel.backgroundColor = [Networking colorWithHexString:@"#F5506B"];
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
